from pydantic import BaseModel, Field
from typing import Generic, TypeVar, Optional, Any, Dict, List

# 泛型定义，用于统一响应格式
T = TypeVar('T')

class ExperimentRequest(BaseModel):
    """实验资源请求模型"""
    user_id: str = Field(..., description="用户唯一标识符")
    experiment_id: str = Field(..., description="实验唯一标识符")
    course_name: str = Field(..., description="课程名称")
    course_type: Optional[str] = Field(None, description="课程类型，如'python'等")

class ExperimentResponse(BaseModel):
    """实验资源响应数据模型"""
    url: str = Field(..., description="资源访问URL")
    last_time: Optional[str] = Field(None, description="最后访问时间")

class ResponseBase(BaseModel, Generic[T]):
    """统一API响应格式"""
    status_code: int = Field(..., description="HTTP 状态码")
    data: Optional[T] = Field(None, description="响应数据")
    message: str = Field(..., description="响应消息") 